package com.joolun.mall.task;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.joolun.mall.entity.ChainPlan;
import com.joolun.mall.service.IChainPlanReserveOrderService;
import com.joolun.mall.service.IChainPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 预留订单
 * 
 * @author Leo
 */
@Component("mallTask")
public class MallTask
{
    @Autowired
    private IChainPlanService planService;

    @Autowired
    private IChainPlanReserveOrderService reserveOrderService;

    public void sync(String params)
    {
        System.out.println("执行定时任务 reserveOrder：" + params);
        Page<ChainPlan> page = new Page<>();
        page.setSize(500);
        ChainPlan dto = new ChainPlan();
        dto.setReserveStatus("0");
        Page<ChainPlan> planPage = planService.page1(page, dto);

        for (ChainPlan plan : planPage.getRecords()) {
            if(plan.getPlanState() == 20){
                reserveOrderService.syncReserve(plan.getId());
            }
        }

        System.out.println("执行有参方法：" + params);
    }


}
